import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/widgets/modal_button.dart';
import 'package:flutter/material.dart';

class ModalServices extends StatelessWidget {
  final List<Map<String, dynamic>> list;
  final String? title;
  final double maxHeightScale;
  const ModalServices(
      {super.key, required this.list, this.title, this.maxHeightScale = 0.85});

  Widget boxRender(
      {required String top,
      required String bottom,
      required BuildContext context}) {
    return Container(
        margin: const EdgeInsets.only(bottom: 18),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(7.5),
            border: Border.all(color: ColorConstant.grey228, width: 1)),
        child: Column(
          children: [
            Container(
                height: 37,
                padding:
                    const EdgeInsets.symmetric(horizontal: EdgeConstant.edge15),
                alignment: Alignment.centerLeft,
                decoration: const BoxDecoration(
                    color: ColorConstant.grey246,
                    border: Border(
                      bottom: BorderSide(
                        color: ColorConstant.grey228,
                        width: 1,
                      ),
                    )),
                child: RichText(
                  text: TextSpan(
                    text: top,
                    style: const TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: FontConstant.f12,
                        color: Colors.black),
                  ),
                )),
            Padding(
                padding: const EdgeInsets.symmetric(
                    vertical: EdgeConstant.edge10,
                    horizontal: EdgeConstant.edge15),
                child: RichText(
                  text: TextSpan(
                      text: bottom,
                      style: const TextStyle(
                          fontSize: FontConstant.f11,
                          color: Color.fromRGBO(0, 0, 0, 0.68),
                          fontWeight: FontWeight.w400)),
                ))
          ],
        ));
  }

  @override
  Widget build(BuildContext context) {
    return EPModalButton(
        title: title,
        maxHeightScale: maxHeightScale,
        children: list
            .map((v) =>
                boxRender(top: v['top'], bottom: v['bottom'], context: context))
            .toList());
  }
}
